<?php
/**
 * View  LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[
    function callback(){
        $("a.edit-status").click(function() {
            $(".ddList").css('visibility', 'hidden');
            $("#"+$(this).attr('rel')).css('visibility', 'visible');
        });

        $("div.live-actions a.dropup").click(function() {
            $("#"+$(this).attr('rel')).css('visibility', 'hidden');	    
        });
        
        $('tr[class^="selectable"]').click(function(){
            $(this).siblings().removeClass('selected');
            $(this).toggleClass('selected');
        })
        
        $("a.select-status").click(function() {
            $.metadata.setType("attr", "rel");

            $.ajax({
                url: "/admin/ajax/select/changelivestatus/id/",
                type: "POST",
                dataType: "json",
                data: {
                    live_id : $(this).metadata().live_id,
                    live_status_id : $(this).metadata().live_status_id
                },
                cache: false,
                success: function(data){
                    $(".ddList").css('visibility', 'hidden'); // Chiudi comunque la popup
                    
                    if(data.errors)
                        $("li#errorLi").show();
                    else
                    {
                        $('#live').pagination({
                            'targetUrl' : '/admin/ajax/list/live',
                            'orderField' : 'live_date',
                            'orderDir' : 'asc'
                        }, callback)
                    }
                },
                error: function(jqXHR, textStatus) {
                    alert( "Request failed: " + textStatus );
                }
            });                    
        });
    }
    
    $(document).ready(function()
    {
        var pagination = $('#live').pagination({
	    'targetUrl' : '/admin/ajax/list/live',
	    'orderField' : 'live_date',
	    'orderDir' : 'asc'
	}, callback)
    });

    //]]>
</script>

<div id="content">
    <div id="summary" class="live">
        <div class="head">
            <h2>Elenco Live</h2>
        </div>
        <div class="body">&nbsp;</div>
    </div>
    <div class="help">
        <h2>Info</h2>
        <br/>Sono evidenziate le attivit&agrave; di oggi.
    </div>    
    <form>
        <ul>
	    <li class="section"><h3></h3></li>
	    <li id="errorLi" style="<?php echo $this->errorMsg ? '' : 'display:none' ?>">
		<h3 id="errorMsgLbl">Si &egrave; verificato un problema durante l'invio del modulo.</h3>
		<p id="errorMsg">
		    <?php echo $this->errorMsg ?>
		</p>
	    </li>	
	
            <li class="addnew">
                <a class="button" href="/admin/live/artisti">
                    <img src="/images/admin/16x16/add-new.png" />Aggiungi nuovo Live
                </a>
            </li>
        </ul>
    </form>

    <table class="log clearfix list" id="live-list">
	<thead>
	    <tr>
                <td class="pagination" colspan="5">
                    <a class="prev" href="javascript: void(0);">&nbsp;</a>
                    <span class="loader">Sto caricando...</span>
                    <a class="next" href="javascript: void(0);">&nbsp;</a>
		</td>
	    </tr>
	</thead>
        <tbody id="live">
            <!-- Questo contenuto verrà rimpiazzato dalla paginazione-->
        </tbody>
    </table>
</div>